export function postManageColumns() {
  return [
    {
      type: "selection",
      width: 55,
      align: "center"
    },
    {
      title: this.$t("module.post.postName"),
      key: "postName",
      width: 180,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.postName
            }
          },
          params.row.postName
        );
      }
    },
    {
      title: this.$t("module.post.postCode"),
      key: "postCode",
      width: 180,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.postCode
            }
          },
          params.row.postCode
        );
      }
    },
    {
      title: this.$t("module.valueSet.ownnerproduct"),
      key: "productName",
      width: 160,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.productName
            }
          },
          params.row.productName
        );
      }
    },
    ...this.getDynamicCol(),
    {
      title: this.$t("common.describe"), // 备注 改为 描述
      key: "remark",
      // width: 160,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.remark
            }
          },
          params.row.remark
        );
      }
    },
    {
      title: this.$t("common.status"),
      align: "left",
      key: "enabled",
      width: 80,
      render: (h, params) => {
        //console.log(params.row.enabled, !!params.row.enabled);
        return h(
          "StatusButton",
          {
            props: {
              status: params.row.enabled == 1 ? "0" : "1"
            }
          },
          !!params.row.enabled ? this.$t("common.enable") : this.$t("common.disable")
        );
      }
    },
    {
      title: this.$t("common.operating"),
      align: "left",
      fixed: "right",
      width: 100,
      render: (h, params) => {
        return h("RowTools", {
          props: {
            data: [
              {
                type: "icon",
                icon: "md-create",
                text: this.$t("common.edit"),
                handle: () => {
                  this.edit(params.row.id, params.row.version);
                }
              },
              {
                type: "icon",
                icon: "ios-body",
                text: this.$t("module.post.assignRole"),
                handle: () => {
                  this.assignRole(params.row);
                }
              },
              {
                type: "icon",
                icon: "md-people",
                text: this.$t("module.post.assignUser"),
                handle: () => {
                  this.assignUser(params.row);
                }
              }
            ]
          }
        });
      }
    }
  ];
}

export function postAssignRoleColumns() {
  return [
    {
      type: "selection",
      width: 55,
      align: "center"
    },
    {
      title: this.$t("module.role.roleName"),
      key: "roleName",
      width: 130,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.roleName
            }
          },
          params.row.roleName
        );
      }
    },
    {
      title: this.$t("module.role.roleCode"),
      key: "roleCode",
      width: 130,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.roleCode
            }
          },
          params.row.roleCode
        );
      }
    },
    {
      title: this.$t("common.describe"), // 备注 改为 描述
      key: "remark",
      // width: 160,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.remark
            }
          },
          params.row.remark
        );
      }
    }
  ];
}

export function postSelectColumns() {
  return [
    {
      type: "selection",
      width: 45,
      align: "center"
    },
    {
      title: this.$t("module.role.roleName"),
      key: "roleName",
      width: 135,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.roleName
            }
          },
          params.row.roleName
        );
      }
    },
    {
      title: this.$t("module.role.roleCode"),
      key: "roleCode",
      width: 135,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.roleCode
            }
          },
          params.row.roleCode
        );
      }
    },
    {
      title: this.$t("module.valueSet.ownnerproduct"),
      key: "productId",
      width: 160,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.productId
            }
          },
          params.row.productId
        );
      }
    },
    ...this.getDynamicCol()
  ];
}

export function postAssignUserColumns() {
  return [
    {
      type: "selection",
      width: 55,
      align: "center"
    },
    {
      title: this.$t("module.userManage.account"),
      key: "userCode",
      width: 130,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.userCode
            }
          },
          params.row.userCode
        );
      }
    },
    {
      title: this.$t("module.userManage.name"),
      key: "userName",
      width: 130,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.userName
            }
          },
          params.row.userName
        );
      }
    },
    {
      title: this.$t("common.describe"), // 备注 改为 描述
      key: "remark",
      // width: 160,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.remark
            }
          },
          params.row.remark
        );
      }
    }
  ];
}

export function postSelectUserColumns() {
  return [
    {
      type: "selection",
      width: 45,
      align: "center"
    },
    {
      title: this.$t("module.userManage.account"),
      key: "username",
      width: 140,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.username
            }
          },
          params.row.username
        );
      }
    },
    {
      title: this.$t("module.userManage.name"),
      key: "name",
      width: 140,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.name
            }
          },
          params.row.name
        );
      }
    },

    {
      title: this.$t("module.userManage.tel"),
      key: "phone",
      width: 120
    },
    {
      title: this.$t("module.userManage.email"),
      key: "email",
      width: 160
      // render: (h, params) => {
      //   return h(
      //     "div",
      //     {
      //       attrs: {
      //         class: "ivu-table-cell ivu-table-cell-ellipsis",
      //         title: params.row.userdesc
      //       }
      //     },
      //     params.row.userdesc
      //   );
      // }
    },
    {
      title: this.$t("module.userManage.buName"),
      key: "buName",
      width: 100,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.buName
            }
          },
          params.row.buName
        );
      }
    },
    {
      title: this.$t("module.userManage.deptName"),
      key: "deptName",
      width: 100,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.deptName
            }
          },
          params.row.deptName
        );
      }
    }
  ];
}
